﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace search
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string url = textBox1.Text;
          
            try
            {
                WebClient client = new WebClient();
                string htmlContent = client.DownloadString(url);

                // 匹配手机号码
                Regex phoneRegex = new Regex(@"(?:(?:\+|00)86)?1[3-9]\d{9}");
                MatchCollection phoneMatches = phoneRegex.Matches(htmlContent);

                // 匹配邮箱
                Regex emailRegex = new Regex(@"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b");
                MatchCollection emailMatches = emailRegex.Matches(htmlContent);

                // 显示结果
                label4.Text = "手机号码："+Environment.NewLine;
                foreach (Match match in phoneMatches)
                {
                    label4.Text += (match.Value + Environment.NewLine);
                }

                label4.Text += (Environment.NewLine + "邮箱地址:" + Environment.NewLine);
                foreach (Match match in emailMatches)
                {
                    label4.Text += (match.Value + Environment.NewLine);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
